package com.ex.kotlin

/**
 * 函数<BR>
 *
 * @author W4255
 * @version [V0.0.1, 2021/8/8]
 * @Description: NA
 */
fun main() {
    val list: List<String> = listOf("apple", "pear", "banana", "watermelon")
    val result: String? = list.maxBy {
        it.length
    }
    println(result)

    val num1 = 10
    val num2 = 20

    val result1: Int = num1AndNum2Test(num1, num2) { a: Int, b: Int ->
        a + b
    }

    val result2: Int = num1AndNum2Test(num1, num2) { a: Int, b: Int ->
        a - b
    }

    println(result1)
    println(result2)
}

fun num1AndNum2Test(num1: Int, num2: Int, operation: (Int, Int) -> Int): Int {
    return operation(num1, num2)
}